[SUBROUTINE]
version = 1.14
icon = center-rect.png
name = _("Rectangle")
type = rectangle
help = _("<b>Create a Rectangle and align X and Y</b>&#10;Corners can be radiused or beveled")
order = act pv h10 x al_x y al_y h11 w h rot h2 ct cr h3 opt xa dir s u_s ugc dpt u_dpt ugcd h4 fp fcs

[PARAM_ACT]
name = _("Active")
icon = enable.png
type = bool
value = 1

[PARAM_PV]
name = _("Show design")
icon = glasses.png
type = bool
value = 1

[PARAM_H10]
name = _("Coords")
type = sub-header

[PARAM_H11]
name = _("Size, rotation")
type = sub-header

[PARAM_FP]
name = _("Finishing pass")
type = combo
options = _("None=0:Clockwise=2:Clockwise full depth=12:Counter-Clockwise=3:Counter-Clockwise full depth=13")
tool_tip = _("Usualy conventional has better finish")
icon = finish.png
value = 0
header = h4

[PARAM_FCS]
name = _("Finishing cut")
header = h4
type = float
minimum_value = 0.01
icon = rect-pocket.png
tool_tip = _("Last finishing cut")
value = 0.04
metric_value = 1.0

[PARAM_X]
name = _("X")
header = h10
type = float
icon = x.png
tool_tip = _("Reference coord")
value = 0.0
metric_value = 0.0

[PARAM_AL_X]
name = _("X axis align")
icon = align-x.png
type = combo
options = _("Left=0:Center=1:Right=2")
header = h10
value = 0
tool_tip = _("Define X reference point")

[PARAM_Y]
name = _("Y")
header = h10
type = float
icon = y.png
tool_tip = _("Reference coord")
value = 0.0
metric_value = 0.0

[PARAM_AL_Y]
name = _("Y axis align")
icon = align-y.png
type = combo
options = _("Top=0:Center=1:Bottom=2")
header = h10
value = 2
tool_tip = _("Define Y reference point")

[PARAM_W]
name = _("Width")
header = h11
type = float
icon = width.png
tool_tip = _("Positive value only")
minimum_value = 0.0
value = 3
metric_value = 75
not_allowed = 0

[PARAM_H]
name = _("Height")
header = h11
type = float
icon = height.png
tool_tip = _("Positive value only")
minimum_value = 0.0
value = 2
metric_value = 50
not_allowed = 0

[PARAM_ROT]
name = _("Rotation")
header = h11
type = float
digits = 2
icon = angle.png
tool_tip = _("Angle rotated")
value = 0
suffix = &#176;

[PARAM_H2]
name = _("Corners")
type = sub-header

[PARAM_CT]
name = _("Type")
header = h2
type = combo
options = _("None=0:Rounded=1:Beveled=2:Inverted Round=3")
icon = corner-style.png
tool_tip = _("Select corner type")
value = 0

[PARAM_CR]
name = _("Radius")
header = h2
type = float
minimum_value = 0.0
icon = corner-radius.png
tool_tip = _("Radius for rounded or distance from apex")
value = 0.0
metric_value = 0.0

[PARAM_H3]
name = _("Milling")
type = sub-header

[PARAM_OPT]
name = _("Option")
header = h3
type = combo
options = _("Inside normal=0:Pocket=1:On the line=2:Outside=3")
icon = g4x.png
tool_tip = _("Select tool path")
value = 0

[PARAM_XA]
name = _("Arc lead-out")
type = bool
icon = lead-out.png
tool_tip = _("Not if on the line")
value = 1
header = h3

[PARAM_DIR]
name = _("Direction")
header = h3
type = combo
options = _("Clockwise=2:Counter-Clockwise=3")
icon = cw-ccw.png
tool_tip = _("Direction of path")
value = 3

[PARAM_S]
name = _("Cut start")
type = combo-user
options = _("User defined=0:Surface=1:Half=2:One quarter=3:Three quarter=4:G-Code=5")
icon = surface.png
tool_tip = _("Pre or user defined")
value = 1
header = h3
links = u_s=0:ugc=5

[PARAM_U_S]
name = _("User start")
type = float
value = 0.0
metric_value = 0.0
header = h3
hidden = 1

[PARAM_UGC]
name = User gcode
type = gcode
value = 
header = h3
hidden = 1

[PARAM_UGCD]
name = User depth gcode
type = gcode
value =
header = h3
hidden = 1

[PARAM_DPT]
name = _("Cut down to")
type = combo-user
options = _("User defined=0:Through=1:Bottom=2:Half=3:One quarter=4:Three quarter=5:G-Code=6")
icon = depth.png
tool_tip = _("Pre or user defined")
value = 1
header = h3
links = u_dpt=0:ugcd=6

[PARAM_U_DPT]
name = _("User depth")
type = float
value = -0.5
metric_value = -12.0
header = h3
hidden = 1

[PARAM_H4]
name = _("Finishing")
type = sub-header


[DEFINITIONS]
content =

[CALL]
content =
	(begin #sub_name)
	(rectangle author : Fernand Veilleux)
	
	o<#self_id_active> if [#param_act]
		o<#self_id_00> if [#param_h GT #param_w] (if narrower than high)
			#<h#ID>   = [#param_w]
			#<w#ID>   = [#param_h]
			#<rot#ID> = [90.0 + #param_rot]
			o<select> CALL [31] [#param_al_x] [-#<h#ID> / 2] [0] [#<h#ID> / 2]
			o<select> CALL [32] [#param_al_y] [-#<w#ID> / 2] [0] [#<w#ID> / 2]
			
		o<#self_id_00> else
			#<w#ID>   = [#param_w]
			#<h#ID>   = [#param_h]
			#<rot#ID> = #param_rot
			o<select> CALL [32] [#param_al_x] [#<w#ID> / 2] [0] [-#<w#ID> / 2]
			o<select> CALL [31] [#param_al_y] [-#<h#ID> / 2] [0] [#<h#ID> / 2]
		o<#self_id_00> endif
		
		#<fcs#ID> = [#param_fcs]
		o<get_min> CALL [37] [2] [#param_cr] [#<h#ID> / 2]
		
		o<select> CALL [33] [#param_s] [#param_u_s] [#<surface>] [#<surface> - #<wp_depth> / 2] [#<surface> - #<wp_depth> / 4] [#<bottom> + #<wp_depth> / 4] [#param_ugc]
		o<select> CALL [34] [#param_dpt] [#param_u_dpt] [#<bottom_through>] [#<bottom>] [#<surface> - #<wp_depth> / 2] [#<surface> - #<wp_depth> / 4] [#<bottom> + #<wp_depth> / 4] [#param_ugcd]
		
		o<rectangle> CALL [#param_x] [#param_y] [#<w#ID>] [#<h#ID>] [#<rot#ID>] [#32] [#31] [#param_ct] [#37] [#param_opt] [#param_dir] [#33] [#34] [#param_pv] [#param_fp] [#<fcs#ID>] [#param_xa]
		
	o<#self_id_active> endif
	(end #sub_name)
